﻿--|--------------------------------------------------------------------------------
--| [GetEntityListByTeamID] - Insert Procedure Script for Entity
--|--------------------------------------------------------------------------------
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id (N'[dbo].[GetEntityListByTeamID]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1) 
  DROP PROCEDURE [dbo].[GetEntityListByTeamID]
GO

CREATE PROCEDURE [dbo].[GetEntityListByTeamID]
(
	@TeamID int
)
AS
	SET NOCOUNT ON

	SELECT
		E.[ID],
		E.[Name],
		E.[Description],
		E.[TeamID],
		E.[EntityTypeID],
		ET.[Name] as [EntityTypeName]
	FROM 
	[Entity] E
	LEFT JOIN [EntityType] ET ON E.[EntityTypeID] = ET.[ID]
	WHERE
		E.[TeamID] = @TeamID
	
GO
 